<?php


namespace app\common\model;


class SystemLog extends BaseModel
{
    /**
     * 记录日志
     * @Author zengxin(573908667@qq.com)
     * @param string $level
     * @param string $module
     * @param $content
     * @param string $msg
     */
    public static function log($content, $msg = '', $module = 'api', $level = 'info')
    {
        if (is_array($content)) $content = json_encode($content);
        self::create([
            'level'        => $level,
            'module'       => $module,
            'controller'   => request()->controller(),
            'action'       => request()->action(),
            'request_data' => $content,
            'msg'          => $msg,
            'request_ip'   => request()->ip(),
            'create_time'  => time(),
        ]);
    }
}